1. About tr
By using TR, you can easily implement many basic sed functions. You can view tr as SED
(Extremely) Simplified variant: it can replace another character with one character, or it can completely remove some characters. You can also use it
This article directory:1.1 Introduction1.2 TR Mapping1.3 Completely corresponding replacement1.4 Compression Symbols1.5 deleting symbols and complement sets1.1 IntroductionTR is primarily used for result set mapping, character compression, and
Tr is short for translate. With this word, you can probably guess what it is! Yes, it can replace another string with one character string, or it can completely remove some characters. You can also use it to remove duplicate characters. Tr is used
TR conversion, compression, truncation, deletion of characters
tr [OPTION].....SET1 [Set2]
Parameters:
-D,--Delete
Deletes the character in string 1 without converting.
-S,--squeeze-repeats
Compresses the recurring string into a string.
Although the contact with Linux for several years, but never used the TR command before learning to find that it is actually a very simple but very useful text processing tool.First look at the man's description of it:NAME tr - translate or
Stream Editor: sedSed ' s/pattern/replace_string/' file #从给定文本中的字符串利用正则表达式进行匹配并替换每一行中第一次符合样式的内容Sed ' s/text/replace/' file > NewFile #替换每一行中第一次符合样式的内容并将替换结果重定向到新文件Sed-i ' s/test/replace/' file #参数-I use to replace the content result of the first
Reprint: http://blog.sina.com.cn/s/blog_4a0824490101hncz.html(1)/C means to replace the characters that are not matched.$temp = "Aaaabcdef";$count = $temp =~tr/a/h/c;Print "$temp \t$count\n";Results: Aaaahhhhh 5(2)/d: Replace all characters on the
IntroductionThe TR command can replace, compress, and delete characters from standard input. It can turn a set of characters into another set of characters.GrammarTR [OPTION] ... SET1 [SET2]Note: SET2 is optionalOPTION:without parameters: replace
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.